<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<%@ include file="/WEB-INF/views/include/easyui.jsp"%>

</head>
<body>
	<div>
		<form id="mainform" action="<%=path %>/system/changePW" method="post">
			<table class="formTable">
				<tr>
					<td>原密码：</td>
					<td> 
					<input
						name="oldpw" value="oldpw" type="password" value=""
						class="easyui-validatebox"
						data-options="required:true" validType="oldpw" invalidMessage="密码不匹配" /></td>
				</tr>
				<tr>
					<td>新密码：</td>
					<td><input name="password" id="password" type="password" 
						value="" class="easyui-validatebox"
						data-options="required:true,validType:['length[6,12]']" /></td>
				</tr>
				<tr>
					<td>重复密码：</td>
					<td><input name="repassword" id="repassword"  type="password" 
						value="" class="easyui-validatebox"
						data-options="required:true" validType="equalTo['#password']"  invalidMessage="两次输入密码不匹配" /></td>
				</tr>
				
			</table>
		</form>
	</div>
	<script type="text/javascript">
	$.extend($.fn.validatebox.defaults.rules, {
        /*必须和某个字段相等*/
        equalTo: { validator: function (value, param) { return $(param[0]).val() == value; }, message: '字段不匹配' },
        oldpw: {  
                validator: function(value){  
                   
                        var oldpw = $('#oldpw').val();  
                        var url = '<%=path %>/system/checkPW?pw='+value;  
                        var ret = $.ajax({url:url,async:false,cache:false,type:"post"}).responseText;//这里一定要用这种方式，如果是在ajax的回调函数里面return就不行。  
                        var b = ret=="true";  
                        if(!b){  
                            $.fn.validatebox.defaults.rules.oldpw.message = '原密码输入有误';  
                        }  
                        return b;  
                    
                },  
                message:''  
            }  
        
       });
	$(function() {
		
		var action = "${action}";
		$('#mainform').form({
			onSubmit : function() {

				var isValid = $(this).form('validate');
				return isValid; // 返回false终止表单提交
			},
			success : function(data) {
				if (successTip(data, dg, d))
					dg.treegrid('reload');
			}
		});
	});
	//上级菜单
	
	</script>
</body>
</html>